﻿using BaseLibrary.CDataContext;
using BaseLibrary.CDataContext.CAttribute;
using BaseLibrary.CDataContext.ConnectionSetting;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DataSyn.DAL.DB.Tables
{
    public class TConnection:CEntity
    {
        [DataColumnAttirbute(Att_AutoIncrement =true, Att_ISPrimary =true)]
        public int ID { get; set; }
        public string ConnectionName { get; set; }
        public string ConnectionString { get; set; }
        public string ProviderString { get; set; }
        [DataColumnAttirbute(Att_IsInDataBase = false)]
        public EProvider Provider
        {
            get
            {
                return BaseLibrary.ClassLibrary.Enum.GetValue<EProvider>(ProviderString);
            }
            set
            {
                ProviderString = BaseLibrary.ClassLibrary.Enum.GetName(value);
            }
        }
        [DataColumnAttirbute(Att_IsInDataBase = false)]
        public string ConnectionDataSource
        {
            get
            {
                return new Conn() {Provider=Provider, Connection = ConnectionString }.Connection;
            }
        }
    }
}
